package com.houtai.edufree.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.houtai.commonutils.Result;
import com.houtai.edufree.entity.StuVideo;
import com.houtai.edufree.service.StuVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xst
 * @since 2022-11-29
 */
@RestController
@RequestMapping("/edufree/stuvideo")
//@CrossOrigin
public class StuVideoController {
    @Autowired
    private StuVideoService stuVideoService;
    /**
     * 查询前八条视频
     * @return videoList
     */
    @GetMapping("index")
    public Result index(){
        QueryWrapper<StuVideo> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("playcount");
        wrapper.last("limit 8");
        List<StuVideo> videoList = stuVideoService.list(wrapper);
        return Result.ok().data("videoList",videoList);
    }
}

